<?php
	//Get user id from session
	$userID=GetLoginUserID();
	$userName=GetLoginUserName();
	
	if($userID==false||$userName==false)
		$result='用户未登陆...';
	else
	{
		if(trim($_POST['action'])=='send')
		{
			$receiverID=intval($_POST['receiverID']);
			$userDAO=GetUserDAO();
			$receiverName=$userDAO->GetUserNameByID($receiverID);
			$msgTitle=edp_db_input(trim($_POST['msgTitle']));
			$msgContent=edp_db_input(trim($_POST['msgContent']));
			
			if($receiverID=='0'||$userID==$receiverID||$receiverName===false)
				$result='不合法的用户ID...';
			else
			{
				if(edp_is_empty_string($msgTitle)||edp_is_empty_string($msgContent))
					$result='缺少主题或内容...';
				else
				{
					$letterDAO=GetLetterDAO();
					$letterDAO->SendLetter(array($receiverID), $userID, $userName, $msgTitle, $msgContent);
					$result = "站内信发送成功...";	
				}
			}
		}
	}
	echo ($result);
	
	/*
	 * yawei把DEL lettet的ajax代码merge到这边，action=del。 
	 */
	

?>